package com.jjty.dataGenerator.akq.entity;

import java.io.Serializable;

public class ResponseResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    
    private Integer status;
    private String errorMsg;
    private T data;
    
    public ResponseResult() {}
    
    public ResponseResult(Integer status, String errorMsg) {
        this.status = status;
        this.errorMsg = errorMsg;
    }
    
    public ResponseResult(Integer status, String errorMsg, T data) {
        this.status = status;
        this.errorMsg = errorMsg;
        this.data = data;
    }
    
    // 静态工厂方法
    public static <T> ResponseResult<T> success() {
        return new ResponseResult<>(0, "请求成功");
    }
    
    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(0, "请求成功", data);
    }
    
    public static <T> ResponseResult<T> fail(String errorMsg) {
        return new ResponseResult<>(1, errorMsg);
    }
    
    // getters and setters
    public Integer getStatus() {
        return status;
    }
    
    public void setStatus(Integer status) {
        this.status = status;
    }
    
    public String getErrorMsg() {
        return errorMsg;
    }
    
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
    
    public T getData() {
        return data;
    }
    
    public void setData(T data) {
        this.data = data;
    }
    
    @Override
    public String toString() {
        return "ResponseResult{" +
                "status=" + status +
                ", errorMsg='" + errorMsg + '\'' +
                ", data=" + data +
                '}';
    }
}    